package com.better.consist;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * Created by liuxin on 2016/4/4.
 */
public enum GlobalTypeEnum implements IEnumBase {
    SC("学校考试", 1, 1), Cl("班级考试", 2, 1)
    ,UP("上",201,2)
    ,DOWN("下",202,2)
    ,ALL("总分",301,3)
    ,SUBJECT("单科",302,3)
    ,FOOT_A("A优踩线生",401,4)
    ,FOOT_B("B优踩线生",402,4)
    ,FOOT_C("C优踩线生",403,4)
    ,FOOT_D("D优踩线生",404,4)
    ,FOOT_E("E优踩线生",405,4)
    ,FOOT_F("F优踩线生",406,4)
    ,SELECT_A("A",501,5)
    ,SELECT_B("B",502,5)
    ,SELECT_C("C",503,5)
    ,SELECT_D("D",504,5)
    ,SELECT_E("E",505,5)
    ,SELECT_F("F",506,5)
    ,HISTORY_COMPARE("历史对比",0,6)
    ,CLASS_COMPARE("班级对比",1,6)
    ;
    private String name;
    private Integer code;
    private Integer teamId;

    GlobalTypeEnum(String name, Integer code, Integer teamId) {
        this.name = name;
        this.code = code;
        this.teamId = teamId;
    }

    public static final Map<Integer, List<Map<String, String>>> EnumMap = EnumFactory.getEnumValuesMap(GlobalTypeEnum.class);

    public static List<Map<String,Object>> getListByTeamId(int teamId) {
        List list = new ArrayList();
        for (GlobalTypeEnum e : GlobalTypeEnum.values()) {
            if (e.getTeamId() - teamId == 0) {
                Map<String,Object> map = new HashMap();
                map.put("code", e.code);
                map.put("name", e.name);
                list.add(map);
            }
        }
        return list;
    }

    public static String getName(int index) {
        try {
            for (GlobalTypeEnum e : GlobalTypeEnum.values()) {
                if (e.getCode() - index == 0) {
                    return e.name;
                }
            }
        } catch (Exception e) {
        }
        return null;
    }

    public static Integer getCodeByName(String name) {
        for (GlobalTypeEnum e : GlobalTypeEnum.values()) {
            if (name != null && name.equals(e.getName())) {
                return e.code;
            }
        }
        return null;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public Integer getTeamId() {
        return teamId;
    }

    public void setTeamId(Integer teamId) {
        this.teamId = teamId;
    }

}
